#include <stdio.h>
#include "student.h"
#include "fileops.h"

int main() {
    int choice;

    loadFromFile(); // 启动时加载数据

    do {
        printf("\n学生信息管理系统\n");
        printf("1. 添加学生信息\n");
        printf("2. 修改学生信息\n");
        printf("3. 删除学生信息\n");
        printf("4. 查询学生信息\n");
        printf("5. 显示所有学生信息\n");
        printf("6. 保存并退出\n");
        printf("请选择操作 (1-6): ");
        scanf("%d", &choice);

        switch (choice) {
        case 1:
            addStudent();
            break;
        case 2:
            modifyStudent();
            break;
        case 3:
            deleteStudent();
            break;
        case 4:
            queryStudent();
            break;
        case 5:
            displayAllStudents();
            break;
        case 6:
            saveToFile();
            printf("数据已保存，再见!\n");
            break;
        default:
            printf("无效选择，请重新选择。\n");
        }
    } while (choice != 6);

    return 0;
}
